package it.eng.suap.web.pdfwe;

import it.eng.get.pdfwe.fillers.jr.JRFillerBean;

import java.io.File;
import java.io.StringReader;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import net.sf.jasperreports.engine.data.JRXmlDataSource;

import org.w3c.dom.Document;
import org.xml.sax.InputSource;

public class JRFillerImpiantoCarburante extends JRFIllerGetAdapter {

	public JRFillerImpiantoCarburante(HttpServletRequest request) throws Exception {
		super(request);
	}

	@Override
	public JRFillerBean getData() throws Exception {
		HashMap<Object, Object> params = new HashMap<Object, Object>();
		params.putAll(_defaultParams);
		
		
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance() ;
		// Now use the factory to create a DOM parser
		DocumentBuilder parser = factory.newDocumentBuilder () ;

		StringReader sr=new StringReader(""); // ModelloUnicoDocument.Factory.parse(new File("/home/antonio/Scrivania/pratica4.xml")).toString());
		Document doc = parser.parse(new InputSource(sr));
		JRXmlDataSource ds = new JRXmlDataSource(doc);
//		params.put("REPORT_DATA_SOURCE",ds);
		return new JRFillerBean(params,ds);
	}

}
